package servlet;

import model.Category;
import service.CategoryService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "admin_category_add",urlPatterns = "/admin/category_add")
public class AdminCategoryAddServlet extends HttpServlet {
    private CategoryService tService = new CategoryService();//用于调用CategoryService的方法
//    private Category id_temp = new Category();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name = request.getParameter("name");//从请求中获取参数

        tService.insert(new Category(name,true));//
        //转发刷新数据
        response.sendRedirect(request.getContextPath() + "/admin/category_list");
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }


}
